package com.lzw.security.service.impl;

import com.lzw.security.entity.*;
import com.lzw.security.exception.MysqlUpdateException;
import com.lzw.security.exception.TidcNulException;
import com.lzw.security.mapper.*;
import com.lzw.security.ov.Status;
import com.lzw.security.ov.UserOV;
import com.lzw.security.service.UpdateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020-3-28 22:46
 * @description：
 * @modified By：
 * @version:
 */
@Slf4j
@Service
public class UpdateServiceImpl implements UpdateService {
    @Autowired
    private CategoryMapper categoryMapper;
    @Autowired
    private CommodityMapper commodityMapper;
    @Autowired
    private SeckillMapper seckillMapper;
    @Autowired
    private DosingMapper dosingMapper;
    @Autowired
    private AccessoryMapper accessoryMapper;
    @Override
    public UserOV<Integer> updateCategory(Category category) throws TidcNulException, MysqlUpdateException {
        UserOV<Integer> userOV = new UserOV<>();
        userOV.setData(categoryMapper.updateCategory(category));
        userOV.getMeta().setStatus(200);
        return userOV;
    }

    @Override
    public UserOV<Integer> updateCommodity(Commodity commodity) throws TidcNulException {
        UserOV<Integer> userOV = new UserOV<>();
        userOV.setData(commodityMapper.updateCommodity(commodity)).getMeta().setStatus(200);
        return userOV;
    }

    @Override
    public UserOV<Integer> updateSeckill(Seckill seckill) {
        UserOV<Integer> userOV = new UserOV<>();
        userOV.setData(seckillMapper.updateSeckill(seckill)).getMeta().setStatus(200);
        return userOV;
    }

    @Override
    public UserOV<Integer> updateDosing(Dosing dosing) {
        UserOV<Integer> userOV = new UserOV<>();
        userOV.setData(dosingMapper.updateDosing(dosing)).getMeta().setStatus(200);
        return userOV;
    }

    @Override
    public UserOV<Integer> updateAccessory(Accessory accessory) {
        UserOV<Integer> userOV = new UserOV<>();
        userOV.setData(accessoryMapper.updateAccessory(accessory)).getMeta().setStatus(200);
        return userOV;
    }

}
